package com.wenyu.wenyuyuedu.activity.personage;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.activity.LoginActivity;
import com.wenyu.wenyuyuedu.activity.circle.EditCircleActivity;
import com.wenyu.wenyuyuedu.activity.circle.ExamineCircleActivity;
import com.wenyu.wenyuyuedu.activity.circle.MyCircleDeitalActivity;
import com.wenyu.wenyuyuedu.activity.homepage.MenberMangeMentActivity;
import com.wenyu.wenyuyuedu.adapter.HelpTabAdapter;
import com.wenyu.wenyuyuedu.adapter.circleAdapter.CheckStutasBean;
import com.wenyu.wenyuyuedu.bean.circle.CircleDetailBean;
import com.wenyu.wenyuyuedu.bean.circle.JoinCircleBean;
import com.wenyu.wenyuyuedu.bean.homepager.MyAttentionInformBean;
import com.wenyu.wenyuyuedu.fragment.TabFragment;
import com.wenyu.wenyuyuedu.fragment.personagefragment.Help_Notice_Fragment;
import com.wenyu.wenyuyuedu.global.ApiWrapper;
import com.wenyu.wenyuyuedu.server.circle.CheckStatusServer;
import com.wenyu.wenyuyuedu.server.circle.JoinCircleServer;
import com.wenyu.wenyuyuedu.server.circle.MyCircleServer;
import com.wenyu.wenyuyuedu.server.homepager.Home_AllAtten_Server;
import com.wenyu.wenyuyuedu.utils.AbSharedUtil;
import com.wenyu.wenyuyuedu.utils.MyToast;
import com.wenyu.wenyuyuedu.utils.SharedConstants;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cn.sharesdk.onekeyshare.OnekeyShare;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/*
* 圈子详情
*/
public class Help_FeedBack_Activity extends ActionBarActivity implements View.OnClickListener {
    Toolbar toolbar;
    @InjectView(R.id.my_detail_left)
    ImageView myDetailLeft;
    @InjectView(R.id.my_detail_title)
    TextView myDetailTitle;
    @InjectView(R.id.my_detail_right)
    ImageView myDetailRight;
    @InjectView(R.id.tv_mycircle_titlecontent)
    TextView tvMycircleTitlecontent;
    @InjectView(R.id.iv_indynamic)
    ImageView ivIndynamic;
    @InjectView(R.id.header)
    ImageView header;
    @InjectView(R.id.help_images)
    ImageView helpImages;
    private Help_Notice_Fragment help_notice_fragment;      //神呐
    private String token;
    private Intent intent;
    /*圈子的id*/
    private String circleId;
    private int page = 1;
    private int intCircleId;
    private Intent intents;
    private String creatorName;
    private String circleName;
    private Dialog detailDialog;
    private Dialog otherPeopleDialog;
    private String circlecover;
    private Activity activity;
    private String login_uid;
    private String circle_find_id;
    private String pubTitle;
    private String user_uid;
    private String circle_uid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_help__feed_back_);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        ButterKnife.inject(this);
        activity = Help_FeedBack_Activity.this;
        //initControls();
        setupToolbar();
        //setupDrawer();
        initView();
        setupViewPager();
        initRequest();
        updataCircleStatus();
    }

    /*用户更新圈子的状态*/
    private void updataCircleStatus() {
        CheckStatusServer checkStatusServer = ApiWrapper.getInstance().create(CheckStatusServer.class);
        Call<CheckStutasBean> checkStatus = checkStatusServer.getCheckStatus(token, circleId);
        checkStatus.enqueue(new Callback<CheckStutasBean>() {
            @Override
            public void onResponse(Call<CheckStutasBean> call, Response<CheckStutasBean> response) {
                CheckStutasBean body = response.body();
                if (body != null) {
                    int code = body.getCode();
                    if (code == 1) {
                        Log.e("TAG", "进入圈子成功");
                    }
                }
            }

            @Override
            public void onFailure(Call<CheckStutasBean> call, Throwable t) {
                System.out.println("Help_FeedBack_Activity: " + t);
                MyToast.showToast(activity, "网络异常，请稍后重试", Toast.LENGTH_SHORT);
            }
        });
    }

    /*获取网络数据*/
    private void initRequest() {
        token = AbSharedUtil.getString(activity, SharedConstants.USER_TOKEN);
        if (token == null) {
            showLoginDialog();
        } else {
            MyCircleServer myCircleServer = ApiWrapper.getInstance().create(MyCircleServer.class);
            Call<CircleDetailBean> circleDetail = myCircleServer.getCircleDetail(token, Integer.parseInt(circleId), 1, page);
            circleDetail.enqueue(new Callback<CircleDetailBean>() {
                @Override
                public void onResponse(Call<CircleDetailBean> call, Response<CircleDetailBean> response) {
                    CircleDetailBean body = response.body();
                    if (body != null) {
                        int code = body.getCode();
                        /*创建圈子用户的uid*/
                        user_uid = body.getInfo().getCircle_uid();
                        if (code == 1) {
                            CircleDetailBean.InfoBeanX info = body.getInfo();
                            /*圈子的封面*/
                            String pubPath = info.getPubPath();
                            if (pubPath != null) {
                                Glide.with(Help_FeedBack_Activity.this)
                                        .load(Uri.parse(pubPath))
                                        .placeholder(R.drawable.circlr_detail_default)
                                        .into(new GlideDrawableImageViewTarget(header) {
                                            @Override
                                            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                                                super.onResourceReady(resource, animation);
                                                helpImages.setVisibility(View.VISIBLE);
                                            }
                                        });

                            }
                            /*创建圈子人的uid*/
                            circle_uid = info.getCircle_uid();
                            /*创建圈子人的昵称*/
                            String pubNickname = info.getPubNickname();
                            if (pubNickname != null) {
                                tvMycircleTitlecontent.setText(pubNickname);
                            }
                            /*圈子的标题*/
                            pubTitle = info.getPubTitle();
                        } else if (code == 0) {
                            /*token错误或者已经失效*/
                            showLoginDialog();
                        } else if (code == 3500) {
                                /*需要登陆后才可以操作*/
                            showLoginDialog();
                        }
                    }
                }

                @Override
                public void onFailure(Call<CircleDetailBean> call, Throwable t) {
                    MyToast.showToast(activity, "数据异常，请稍后重试", Toast.LENGTH_SHORT);
                }
            });
        }
    }

    /*初始化标题栏上的点击事件*/
    private void initView() {
        intents = new Intent();
        intent = getIntent();
        token = AbSharedUtil.getString(Help_FeedBack_Activity.this, SharedConstants.USER_TOKEN);
        //creatorName = intent.getStringExtra("creatorName");
        circleId = intent.getStringExtra("circleId");
        circleName = intent.getStringExtra("circleName");
        login_uid = intent.getStringExtra("login_find_uid");
        circle_find_id = intent.getStringExtra("myattention");
        // circlecover = intent.getStringExtra("circlecover");
        intCircleId = Integer.parseInt(circleId);
        myDetailLeft.setOnClickListener(this);
        myDetailRight.setOnClickListener(this);
        if (circleName != null) {
            myDetailTitle.setText(circleName);
        }
        ivIndynamic.setOnClickListener(this);

    }

    private void setupDrawer() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

    }

    /*
      * 初始化CollapsingToolbarLayout布局中的控件
      * */
    private TabLayout tab_help_title;    //定义TabLayout
    private ViewPager vp_help_pager;     //定义viewPager
    private List<Fragment> list_fragment;        //定义要装fragment的集合
    private List<String> list_title;             //tab名称列表
    private FragmentPagerAdapter fAdapter;       //定义adapter

    private void initControls() {
        tab_help_title = (TabLayout) findViewById(R.id.tab_help_title);
        vp_help_pager = (ViewPager) findViewById(R.id.vp_help_pager);
        //初始化三个fragment
        help_notice_fragment = new Help_Notice_Fragment();
        //将fragment存放到集合当中
        list_fragment = new ArrayList<>();
        list_fragment.add(help_notice_fragment);
        //定义存放名字的集合
        list_title = new ArrayList<>();
        list_title.add("全部");
        list_title.add("神呐");
        //设置TabLayout的模式
        tab_help_title.setTabMode(TabLayout.MODE_FIXED);
        //为TabLayout添加tab名称
        tab_help_title.addTab(tab_help_title.newTab().setText(list_title.get(0)));
        tab_help_title.addTab(tab_help_title.newTab().setText(list_title.get(1)));
        fAdapter = new HelpTabAdapter(this.getSupportFragmentManager(), list_fragment, list_title);
        //viewpager加载adapter
        vp_help_pager.setAdapter(fAdapter);
        //tab_FindFragment_title.setViewPager(vp_FindFragment_pager);
        //TabLayout加载viewpager
        tab_help_title.setupWithViewPager(vp_help_pager);
        //tab_FindFragment_title.set
        setCollapse();
    }

    /*初始化toolbar*/
    private void setupToolbar() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setHomeButtonEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    }

    /*collapse_toolbar*/
    private void setCollapse() {
        CollapsingToolbarLayout viewById = (CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar);
        viewById.setTitle("");

    }

    private void setupViewPager() {
        final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_help_pager);
        setupViewPager(viewPager);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_help_title);
        tabLayout.setupWithViewPager(viewPager);
    }

    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        adapter.addFrag(new TabFragment(), "全部");
        adapter.addFrag(new Help_Notice_Fragment(), "神贴");


        viewPager.setAdapter(adapter);
    }

    static class ViewPagerAdapter extends FragmentPagerAdapter {

        private final List<Fragment> mFragmentList = new ArrayList<>();
        private final List<String> mFragmentTitleList = new ArrayList<>();

        public ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        public void addFrag(Fragment fragment, String title) {
            mFragmentList.add(fragment);
            mFragmentTitleList.add(title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentTitleList.get(position);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            /*返回*/
            case R.id.my_detail_left:
                finish();
                break;
            /*右侧的dialog*/
            case R.id.my_detail_right:
                String login_uid = this.login_uid;
                String circle_find_id = this.circle_find_id;
                /*判断是不是自己的圈子*/
                if (login_uid.equals(circle_find_id)) {
                    /*自己的圈子*/
                    showFromDialog();
                } else {
                    //别人的圈子
                    showFromOtherPeopleDialog();
                }
                break;
            /*发表的图标*/
            case R.id.iv_indynamic:
                intent.setClass(Help_FeedBack_Activity.this, MyCircleDeitalActivity.class);
                intent.putExtra("circle_title", pubTitle);
                startActivity(intent);
                break;
        }
    }

    /*
    * 显示悬浮的图片
    * */
    public void showIndyamic() {
        ivIndynamic.setVisibility(View.VISIBLE);
    }

    /*
    * 隐藏悬浮的图片
    * */
    public void hideIndyamic() {
        ivIndynamic.setVisibility(View.INVISIBLE);
    }

    AlertDialog ad;
    private TextView quxiao;
    private TextView queding;

    /*token错误或者已失效*/
    private void showLoginDialog() {
        ad = new AlertDialog.Builder(Help_FeedBack_Activity.this).create();
        ad.show();
        Window window = ad.getWindow();
        window.setContentView(R.layout.dailog_login);
        quxiao = (TextView) window.findViewById(R.id.dialog_login_quxiao);
        queding = (TextView) window.findViewById(R.id.dialog_login_queding);
        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ad.dismiss();
                Help_FeedBack_Activity.this.finish();
            }
        });
        queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Help_FeedBack_Activity.this, LoginActivity.class);
                startActivity(intent);
                ad.dismiss();
                Help_FeedBack_Activity.this.finish();
            }
        });
    }

    /*右上角来自的dialog----我的圈子*/
    private void showFromDialog() {
        View view = getLayoutInflater().inflate(R.layout.invitation_from_dialog,
                null);
        detailDialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        this.detailDialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = this.detailDialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        // 设置显示位置
        this.detailDialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        this.detailDialog.setCanceledOnTouchOutside(true);
        this.detailDialog.show();
    }

    /*来自我的圈子的dailog的取消*/
    public void from_cancel(View view) {
        detailDialog.cancel();

    }

    /*来自dailog的分享*/
    public void btn_share(View view) {
        showShare();
        detailDialog.cancel();
    }

    /*来自dailog的编辑书圈*/
    public void btn_edite_circle(View view) {
        intent.setClass(Help_FeedBack_Activity.this, EditCircleActivity.class);
        intent.putExtra("circle_id", circleId);
        startActivity(intent);
        detailDialog.cancel();
    }

    /*来自dailog的成员管理*/
    public void btn_member_manage(View view) {
        intent.setClass(Help_FeedBack_Activity.this, MenberMangeMentActivity.class);
        intent.putExtra("object_id", circleId);
        intent.putExtra("helpfeed_user_id", user_uid);
        startActivity(intent);
        detailDialog.cancel();
    }


    /*右上角来自的dialog----别人的圈子*/
    private void showFromOtherPeopleDialog() {
        View view = getLayoutInflater().inflate(R.layout.invitation_from_otherpeople_dialog,
                null);
        otherPeopleDialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        this.otherPeopleDialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = this.otherPeopleDialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        // 设置显示位置
        this.otherPeopleDialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        this.otherPeopleDialog.setCanceledOnTouchOutside(true);
        this.otherPeopleDialog.show();
    }

    /*来自其他人的圈子的dailog的取消*/
    public void otherpeople_cancel(View view) {
        otherPeopleDialog.cancel();
    }

    /*来自其他人的圈子的dailog的分享*/
    public void btn_otherpeople_share(View view) {
        showShare();
        otherPeopleDialog.cancel();
    }

    /*来自其他人的圈子的dailog的举报*/
    public void btn_report_otherpeople_circle(View view) {
        reportInvitaionDialog();
    }

    /*举报的列表---帖子的*/
    private Dialog respotInvitationDialog;

    private void reportInvitaionDialog() {
        View view = getLayoutInflater().inflate(R.layout.invitation_report_dialog,
                null);
        respotInvitationDialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        respotInvitationDialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = respotInvitationDialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        // 设置显示位置
        respotInvitationDialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        respotInvitationDialog.setCanceledOnTouchOutside(true);
        respotInvitationDialog.show();
    }

    /*广告垃圾的举报---帖子的*/
    public void invitition_advertising_grabage(View view) {
        Inform(1 + "");
    }

    /*色情淫秽的举报--帖子的*/
    public void invitition_plagiarize(View view) {
        Inform(2 + "");
    }

    /*恶意营销*/
    public void invitition_hostility(View view) {
        Inform(3 + "");
    }

    /*人身攻击*/
    public void invitition_other(View view) {
        Inform(4 + "");
    }

    /*取消*/
    public void invitition_report_cancel(View view) {
        respotInvitationDialog.cancel();
    }

    /*来自其他人的圈子的dailog的查看书圈*/
    public void btn_examine_circle(View view) {
        intent.setClass(activity, ExamineCircleActivity.class);
        intent.putExtra("helpfeedbackactivity_to_examinactivity", circleId);
        startActivity(intent);
        otherPeopleDialog.cancel();
    }

    /*来自其他人的圈子的dailog的退出圈子*/
    public void btn_quit_circle_manage(View view) {
        otherPeopleDialog.cancel();
        quietCollect();
    }

    /*退出书圈*/
    private void quietCollect() {
        JoinCircleServer joinCircleServer = ApiWrapper.getInstance().create(JoinCircleServer.class);
        Call<JoinCircleBean> joinBean = joinCircleServer.getJoinBean(token, Integer.parseInt(circleId), 1, 2);
        joinBean.enqueue(new Callback<JoinCircleBean>() {
            @Override
            public void onResponse(Call<JoinCircleBean> call, Response<JoinCircleBean> response) {
                JoinCircleBean body = response.body();
                if (body != null) {
                    int code = body.getCode();
                    if (code == 1) {
                        MyToast.showToast(activity, "退出书圈成功", Toast.LENGTH_SHORT);
                        finish();
                    } else if (code == 0) {
                        showLoginDialog();
                    } else if (code == 2500) {
                        MyToast.showToast(activity, "需要登陆后才可以操作", Toast.LENGTH_SHORT);
                    } else if (code == 2503) {
                        MyToast.showToast(activity, "您已经取消过对该书圈的收藏了！", Toast.LENGTH_SHORT);
                    } else if (code == 2504) {
                        MyToast.showToast(activity, "您还没有收藏过该书圈！", Toast.LENGTH_SHORT);
                    } else if (code == 2506) {
                        MyToast.showToast(activity, "抱歉您的账户被暂时限制了，无法进行此操作！", Toast.LENGTH_SHORT);
                    } else if (code == 2507) {
                        MyToast.showToast(activity, "系统繁忙，请您稍后再试！", Toast.LENGTH_SHORT);
                    }
                }
            }

            @Override
            public void onFailure(Call<JoinCircleBean> call, Throwable t) {
                MyToast.showToast(activity, "系统繁忙，请您稍后再试！", Toast.LENGTH_SHORT);
            }
        });

    }

    private void showShare() {
        OnekeyShare oks = new OnekeyShare();
        //关闭sso授权
        oks.disableSSOWhenAuthorize();
        oks.setSilent(false);
        oks.setDialogMode();
        // title标题，印象笔记、邮箱、信息、微信、人人网、QQ和QQ空间使用
        oks.setTitle("文鱼阅读");
        // titleUrl是标题的网络链接，仅在Linked-in,QQ和QQ空间使用
        // oks.setTitleUrl("http://sharesdk.cn");
        // text是分享文本，所有平台都需要这个字段
        // oks.setText(activity);
        //分享网络图片，新浪微博分享网络图片需要通过审核后申请高级写入接口，否则请注释掉测试新浪微博
        oks.setImageUrl("http://www.iwenyu.cn/Public/images/share.jpg");
        // imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
        //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
        // url仅在微信（包括好友和朋友圈）中使用
        // oks.setUrl("http://sharesdk.cn");
        // comment是我对这条分享的评论，仅在人人网和QQ空间使用
        oks.setComment("我是测试评论文本");
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite("ShareSDK");
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl("http://sharesdk.cn");

        // 启动分享GUI
        oks.show(this);
    }

    /*举报的接口-----可以举报帖子--可以举报圈子-=------inform(是圈子还是帖子)--- type(是举报的类型)*/
    private void Inform(String type) {
        Home_AllAtten_Server home_allAtten_server = ApiWrapper.getInstance().create(Home_AllAtten_Server.class);
        Call<MyAttentionInformBean> myAttentionInformBeanCall = home_allAtten_server.postInform(token, circle_uid, circleId, 1 + "", type);
        myAttentionInformBeanCall.enqueue(new Callback<MyAttentionInformBean>() {
            @Override
            public void onResponse(Call<MyAttentionInformBean> call, Response<MyAttentionInformBean> response) {
                MyAttentionInformBean body = response.body();
                if (body != null) {
                    int code = body.getCode();
                    if (code == 1) {
                        if (otherPeopleDialog != null && respotInvitationDialog != null) {
                            MyToast.showToast(activity, "举报成功，等待审核", Toast.LENGTH_SHORT);
                            otherPeopleDialog.cancel();
                            respotInvitationDialog.cancel();
                        }
                    } else if (code == 0) {
                        showLoginDialog();
                    } else if (code == 2900) {
                        MyToast.showToast(activity, "需要登陆后才可以操作", Toast.LENGTH_SHORT);
                    } else if (code == 2901) {
                        MyToast.showToast(activity, "抱歉您的账户被暂时限制了，无法进行此操作", Toast.LENGTH_SHORT);
                    } else if (code == 2904) {
                        MyToast.showToast(activity, "系统繁忙请稍后再试！", Toast.LENGTH_SHORT);
                    }
                }
            }

            @Override
            public void onFailure(Call<MyAttentionInformBean> call, Throwable t) {
                MyToast.showToast(activity, "系统繁忙请稍后再试！", Toast.LENGTH_SHORT);
            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}
